// 
// Copyright (c) 2006-2010 Ben Motmans
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// Author(s):
//    Ben Motmans <ben.motmans@gmail.com>
//

using System;

namespace Anculus.Core
{
	public class CustomLogFormatter : ILogFormatter
	{
		public CustomLogFormatter ()
		{
		}
		
		public string Format (LogEntry entry)
		{
			throw new System.NotImplementedException();
		}
		
		
		public void LoadSettings (IConfigurationSection section)
		{
			throw new System.NotImplementedException();
		}
		
		/// <summary>
		/// Writes the specified log entry.
		/// </summary>
		/// <param name="timestamp">The timestamp.</param>
		/// <param name="level">The level.</param>
		/// <param name="threadId">The id of the thread.</param>
		/// <param name="threadName">The name of the thread.</param>
		/// <param name="logger">The logger.</param>
		/// <param name="category">The category.</param>
		/// <param name="source">The source.</param>
		/// <param name="message">The message.</param>
		/// <param name="ex">The ex.</param>
		/*public virtual void WriteEntry (string timestamp, LogLevel level, int threadId, string threadName, string category, string logger, string source, string message, Exception ex)
		{
			//"%timestamp [%level] (%threadid) %category %logger: %msg %source%ex";
			

			string exinfo = FormatException (ex);
			
			string entry = String.Concat (
				Log.TimeStampFormat == null ? "" : timestamp.ToString (timeStampFormat),
				GetLevelString (level),
				category == null ? "" : category,
				logger,
				source,
				message.ToString (),
				exinfo
			);
			
			int len = logFormatIndices.Length;
			int prev = 0;

			for (int i = 0; i < len; i++) {
				switch (logFormatIndices[i].Match) {
					case "%timestamp":
						Write (LogFormatParameter.Timestamp, timestamp.ToString (timeStampFormat));
						break;
					case "%level":
						Write (LogFormatParameter.Level, GetLevelString (level));
						break;
					case "%category":
						Write (LogFormatParameter.Category, category);
						break;
					case "%logger":
						Write (LogFormatParameter.Logger, logger);
						break;
					case "%source":
						Write (LogFormatParameter.None, Environment.NewLine + "\tsource: ");
						Write (LogFormatParameter.Source, source);
						break;
					case "%msg":
						Write (LogFormatParameter.Message, message.ToString ());
						break;
					case "%threadid":
						Write (LogFormatParameter.ThreadId, System.Threading.Thread.CurrentThread.ManagedThreadId.ToString ());
						break;
					case "%threadname":
						Write (LogFormatParameter.ThreadName, System.Threading.Thread.CurrentThread.Name);
						break;
					case "%ex":
						if (ex != null) {
							Write (LogFormatParameter.Exception, String.Concat (Environment.NewLine, "\texception: ", ex.Message, Environment.NewLine, ex.StackTrace));

							if (ex.InnerException != null)
								Write (LogFormatParameter.Exception, String.Concat (Environment.NewLine, "\tinner exception: ", ex.InnerException.Message, Environment.NewLine, ex.InnerException.StackTrace));
						}
						break;
					case "\\n":
						Write (LogFormatParameter.None, Environment.NewLine);
						break;
					case "\\t":
						Write (LogFormatParameter.None, "\t");
						break;
					default:
						Write (LogFormatParameter.None, logFormatIndices[i].Match);
						break;
				}

				//write non-replaced chunks of the format string
				if (logFormatIndices[i].Index != prev)
					Write (LogFormatParameter.None, logFormat.Substring (prev, logFormatIndices[i].Index - prev));

				prev = logFormatIndices[i].Index + logFormatIndices[i].Length;
			}

			if (prev < len)
				Write (LogFormatParameter.None, logFormat.Substring (prev));
		}
		*/
	}
}
